package com.sd.service.impl;

import com.sd.dao.BusinessHospitalDao;
import com.sd.entity.BusinessHospital;
import com.sd.entity.StudentHospital;
import com.sd.service.BusinessHospitalService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (BusinessHospital)表服务实现类
 *
 * @author makejava
 * @since 2021-06-15 10:46:03
 */
@Service("businessHospitalService")
public class BusinessHospitalServiceImpl implements BusinessHospitalService {
    @Resource
    private BusinessHospitalDao businessHospitalDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public BusinessHospital queryById(Integer id) {
        return this.businessHospitalDao.queryById(id);
    }

    @Override
    public List<BusinessHospital> queryAll(BusinessHospital businessHospital) {
        return businessHospitalDao.queryAll(businessHospital);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<BusinessHospital> queryAllByLimit(int offset, int limit) {
        return this.businessHospitalDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param businessHospital 实例对象
     * @return 实例对象
     */
    @Override
    public BusinessHospital insert(BusinessHospital businessHospital) {
        this.businessHospitalDao.insert(businessHospital);
        return businessHospital;
    }

    /**
     * 修改数据
     *
     * @param businessHospital 实例对象
     * @return 实例对象
     */
    @Override
    public BusinessHospital update(BusinessHospital businessHospital) {
        this.businessHospitalDao.update(businessHospital);
        return this.queryById(businessHospital.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.businessHospitalDao.deleteById(id) > 0;
    }




    @Override
    public Map<String, Long> getCount() {
        return businessHospitalDao.getCount();
    }

    @Override
    public boolean deleteBusinessByIds(List<BusinessHospital> businessList) {
        int i = businessHospitalDao.deleteBusinessByIds(businessList);
        if(i>0){
            return true;
        }
        return false;
    }
}